{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b19ecf57-4b7e-4023-bee5-1d510f5a4d92",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2000 2004 2008 2012 2016 2020 2024 2028 2032 2036 2040 2044 2048 2052 2056 2060 2064 2068 2072 2076 2080 2084 2088 2092 2096 2104 2108 2112 2116 2120 2124 2128 2132 2136 2140 2144 2148 2152 2156 2160 2164 2168 2172 2176 2180 2184 2188 2192 2196 2204 2208 2212 2216 2220 2224 2228 2232 2236 2240 2244 2248 2252 2256 2260 2264 2268 2272 2276 2280 2284 2288 2292 2296 2304 2308 2312 2316 2320 2324 2328 2332 2336 2340 2344 2348 2352 2356 2360 2364 2368 2372 2376 2380 2384 2388 2392 2396 2400 2404 2408 2412 2416 2420 2424 2428 2432 2436 2440 2444 2448 2452 2456 2460 2464 2468 2472 2476 2480 2484 2488 2492 2496 2504 2508 2512 2516 2520 2524 2528 2532 2536 2540 2544 2548 2552 2556 2560 2564 2568 2572 2576 2580 2584 2588 2592 2596 2604 2608 2612 2616 2620 2624 2628 2632 2636 2640 2644 2648 2652 2656 2660 2664 2668 2672 2676 2680 2684 2688 2692 2696 2704 2708 2712 2716 2720 2724 2728 2732 2736 2740 2744 2748 2752 2756 2760 2764 2768 2772 2776 2780 2784 2788 2792 2796 2800 2804 2808 2812 2816 2820 2824 2828 2832 2836 2840 2844 2848 2852 2856 2860 2864 2868 2872 2876 2880 2884 2888 2892 2896 2904 2908 2912 2916 2920 2924 2928 2932 2936 2940 2944 2948 2952 2956 2960 2964 2968 2972 2976 2980 2984 2988 2992 2996 "
     ]
    }
   ],
   "source": [
    "import calendar\n",
    "for y in range (2000,3001):\n",
    "    #方法一。使用一个逻辑表达式包含所有的闰年条件\n",
    "    if ((y % 4 == 0 and y % 100 != 0) or y % 400 == 0):\n",
    "        print(y,end=' ')\n",
    "\n",
    "\n",
    "    #方法二。使用嵌套的if语句，相关语句如下：\n",
    "    #for y in range (2000,3001):\n",
    "    #    if (y % 400 == 0): print(y,end=' ')\n",
    "    #    else:\n",
    "    #        if (y % 4 == 0):\n",
    "    #            if (y % 100 != 0): print(y,end=' ')     \n",
    "\n",
    "    #方法三。使用if-elif语句，相关语句如下：\n",
    "    #for y in range (2000,3001):\n",
    "    #    if (y % 400 == 0): print(y,end=' ')\n",
    "    #    elif (y % 4 != 0): pass\n",
    "    #    elif (y % 100 != 0): print(y,end=' ')\n",
    "\n",
    "    #方法四。使用calendar模块的isleap函数来判断闰年，相关语句如下：\n",
    "    #if (calendar.isleap(y)): print(y,end=' ')\n",
    "   \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "15a89c69-e57c-4d5d-b301-404d51d6f929",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
